package ui.footer 
{
	import com.asual.swfaddress.SWFAddress;
	import com.greensock.TweenMax;
	import flash.display.MovieClip;
	import flash.display.Shape;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import utils.ShapeUtil;
	import utils.TextFieldUtil;
	
	/**
	 * ...
	 * @author usual
	 */
	public class SubMenuItem extends MovieClip 
	{
		private var _xmlData:XML;
		private var _labelTxt:TextField;
		public var line:Shape;
		public function SubMenuItem(xmlData:XML)
		{
			_xmlData = xmlData;
			addEventListener(Event.ADDED_TO_STAGE, _build);
			//visible = false;
		}
		
		private function _build(e:Event):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, _build);
			addWording();
		}
		
		private function addWording():void 
		{
			_labelTxt = new TextField();
			_labelTxt.autoSize = TextFieldAutoSize.LEFT;
			_labelTxt.mouseEnabled = false;
			//_labelTxt.htmlText = _xmlData.word;
			TextFieldUtil.setText(_labelTxt, "<social>"+_xmlData.word+"</social>");
			addChild(_labelTxt);
			
			line = ShapeUtil.getLineH(_labelTxt.width,0x01fbfb);
			addChild(line);
			line.alpha = 0;
			line.y = _labelTxt.y + _labelTxt.height;
			addEventListener(MouseEvent.MOUSE_OVER, _over);
			addEventListener(MouseEvent.MOUSE_OUT, _out);
			addEventListener(MouseEvent.CLICK, _click);
			buttonMode = true;
		}
		
		private function _click(e:MouseEvent):void 
		{
			SWFAddress.href(_xmlData.url, '_blank');
		}
		
		private function _out(e:MouseEvent):void 
		{
			TweenMax.killChildTweensOf(this);
			TweenMax.to(this,.5,{removeTint:true});
			TweenMax.to(line,.5,{alpha:0});
		}
		
		private function _over(e:MouseEvent):void 
		{
			TweenMax.to(this,.5,{tint:0x01fbfb});
			TweenMax.to(line,.5,{alpha:1});
		}
		
	}

}